home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2715 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  53 lines

  1. Path: holly.ACNS.ColoState.EDU!not-for-mail
  2. From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: getch() and cin
  5. Date: 19 Jan 1996 01:20:02 -0700
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4dnk7i$36ha@holly.ACNS.ColoState.EDU>
  8. References: <4dncee$4g2@news.cencom.net>
  9. NNTP-Posting-Host: holly.acns.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Will Senn (wsenn@cencom.net) wrote:
  13. :     I would appreciate it if someone could tell me if there is a way
  14. : to make cin read input without line buffering (waiting for the carriage
  15. : return)?  I know all about getch() in conio.h, however I would prefer
  16. : sticking to stream input included in iostream.h.  Any help along these lines
  17. : would be greatly appreciated.
  18.  
  19. :     Before anyone freaks, I spent several hours with the various search
  20. : engines on the web as well as looking through a ton of related newsgroups
  21. : before I posted this seemingly obvious question.  The closest I came to an
  22. : answer was a reference to a FAQ 309, a depressingly hard to find faq, quoted
  23. : in the C++ Faq.
  24.  
  25. : Thanks for any help,
  26. ------------------------------------
  27.  
  28. void main()
  29. {
  30.   char Temp;
  31.  
  32.   cin.get(Temp);
  33.   while(Temp != '\n') cin.get(Temp);
  34.  
  35.   return;
  36. }
  37. -------------------------------------
  38.  
  39. This will read a character at a time until the newline.  The get() 
  40. member is what you want.  Questions?
  41.  
  42. // ------------ BEGIN SIGNATURE ---------------
  43. #include <iostream.h>
  44. void main()
  45. {
  46.   cout<<"\aName:\tCorby S. Hudnall\n";
  47.   cout<<"School:\tColorado State University\n";
  48.   cout<<"EMail\tcorbyh@holly.colostate.edu\n";
  49.   cout<<"URL\thttp://holly.colostate.edu/~corbyh/\n";
  50. }
  51. // ------------- END SIGNATURE ----------------
  52.  
  53.